import 'package:flutter/material.dart';

//  {
//     "createTime": "2024-08-15 21:49:48",
//     "orderState": 2,
//     "image": "https://yanxuan-item.nosdn.127.net/a09de222ed32efa8ffe359b1d5780574.jpg",
//     "name": "茶水分离杯耐热隔热玻璃杯",
//     "totalNum": 2,
//     "curPrice": 119.5,
//     "totalMoney": 119.5,
//     "attrsText": "规格:白色240ml"
// }

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      appBar: AppBar(
        title: const Text('案例-商品订单信息'),
        backgroundColor: Colors.red,
      ),
      body: const List(),
    ));
  }
}

class List extends StatelessWidget {
  const List({super.key});

  @override
  Widget build(BuildContext context) {
    return ListView(
      children: const [
        Content(),
        Content(),
        Content(),
        Content(),
        Content(),
        Content()
      ],
    );
  }
}


class Content extends StatelessWidget {
  const Content({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
        padding: const EdgeInsets.all(10),
        child: const Column(
          children: [
            OrderHeader(),
            OrderContent(),
            OrderFooter(),
          ],
        ));
  }
}

class OrderHeader extends StatelessWidget {
  const OrderHeader({super.key});

  @override
  Widget build(BuildContext context) {
    return const Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Text('2024-08-15 21:49:48'),
        Text(
          '待发货',
          style: TextStyle(color: Colors.yellow),
        )
      ],
    );
  }
}

class OrderContent extends StatelessWidget {
  const OrderContent({super.key});

  @override
  Widget build(BuildContext context) {
    return const Row(
      children: [
        Expanded(
          flex: 1,
          child: Image(
            image: NetworkImage(
                'https://yanxuan-item.nosdn.127.net/a09de222ed32efa8ffe359b1d5780574.jpg'),
            width: 100,
          ),
        ),
        Expanded(flex: 2, child: RightContent())
      ],
    );
  }
}

class OrderFooter extends StatelessWidget {
  const OrderFooter({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(children: [
      const Row(
        mainAxisAlignment: MainAxisAlignment.end,
        children: [Text('合计：￥239')],
      ),
      const Divider(),
      Row(mainAxisAlignment: MainAxisAlignment.end, children: [
        Container(
            padding: const EdgeInsets.fromLTRB(6, 10, 6, 10),
            decoration: BoxDecoration(
              border: Border.all(color: Colors.black12, width: 1),
            ),
            child: const Text('再次购买'))
      ])
    ]);
  }
}

class RightContent extends StatelessWidget {
  const RightContent({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
        padding: const EdgeInsets.fromLTRB(12,0,0,0),
        child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              const Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Expanded(
                      child: Text(
                          '茶水分离杯耐热隔热玻璃杯茶水分离杯耐热隔热玻璃杯茶水分离杯耐热隔热玻璃杯茶水分离杯耐热隔热玻璃杯',
                          maxLines: 2)),
                  Text('x2'),
                ],
              ),
              Container(
                  padding: const EdgeInsets.all(5),
                  margin: const EdgeInsets.fromLTRB(0, 10, 0, 10),
                  decoration: const BoxDecoration(color: Colors.black12),
                  child: const Text(
                    '规格:白色240ml',
                    style: TextStyle(color: Colors.black26),
                  )),
              const Text('￥119.5')
            ]));
  }
}
